@extends('admin.layout.layout', ['row' => @$page])

@section('contain')

    <div class="portlet">
        <div class="portlet-title">
            <div class="caption">
                <x-portlet-breadcrumb :page="$page"></x-portlet-breadcrumb>
            </div>
            <div class="actions">
                {{--@if(session('admin.user_type')==1)
                    <div class="item">
                        <a href="/admin/dealer/create" class="btn btn-primary">{{ ts('addnew') }}</a>
                    </div>
                @endif--}}
            </div>
        </div>

        <div class="filter-wrapper">
            <form action="/{{ request()->path() }}/" class="form-inline filter-form">
                <div class=" input-group mb-3 custom-control-inline">
                    <input type="text" class="form-control s-input" name="value" value="{{ request()->input('value') }}" placeholder="{{ ts('dealerSEARCHTEXT') }}">
                </div>
                <div class="input-group mb-3 custom-control-inline">
                    <select name="status" class="form-control">
                        <option value="">{{ ts('select').' '.ts('status') }}</option>
                        <option value="1" {{ request()->input('status') == 1 ? 'selected' : '' }}>{{ ts('jy') }}</option>
                        <option value="2" {{ request()->input('status') == 2 ? 'selected' : '' }}>{{ ts('deactive') }}</option>
                    </select>
                </div>
                <div class="input-group mb-3 custom-control-inline">
                    <select name="mdtype" class="form-control">
                        <option value="">{{ ts('select').' '.ts('jxsjb') }}</option>
                        @foreach(range(1,4) as $v)
                            <option value="{{ $v }}" {{ request()->input('mdtype') == $v ? 'selected' : '' }}>{{ ts('mdtype'.$v) }}</option>
                        @endforeach
                    </select>
                </div>

                <x-flatpickr-date-range></x-flatpickr-date-range>

                <div class="mb-3">
                    <button class="btn btn-primary">{{ ts('SEARCH') }}</button>
                    <a href="/admin/dealer/" class="btn btn-warning">{{ ts('RESET') }}</a>
                </div>

            </form>
        </div>
        <div>
            <style>
                .table-responsive    th{
                    word-break:keep-all;
                }
            </style>
            <div class="text-nowrap">
                <table class="table text-nowrap bt-table d-none">
                    <thead>
                    <tr class="order_column text-center">
                        <th class="text-center">{{ ts('SELECT') }}</th>
                        <th data-column="id">{{ ts('sequence') }}</th>
                        {{--<th data-column="unique_id">{{ ts('dealerid') }}</th>--}}
                        <th data-column="abbr">{{ ts('jxsMC') }}</th>
                        <th>{{ ts('JXSJB') }}</th>
                        <th>{{ ts('sdqy') }}</th>
                        {{--<th data-column="unique_id">{{ ts('jxsMC') }}</th>
                        <th data-column="company_name">{{ ts('COMPANYNAME') }}</th>--}}
                        <th data-column="first_name">{{ ts('CONTACTPERSON') }}</th>
                        <th data-column="phone_number">{{ ts('CONTACTINFORMATION') }}</th>
                        <th data-column="status">{{ ts('STATUS') }}</th>
                        <th style="width:270px">{{ ts('OPERATIONS') }}</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($data as $k => $v)
                        <tr class="item-list">
                            <td class="text-center">
                                <input type="checkbox" class="roll_icheck icheck_input" name="ids[]" value="{{ $v->id }}">
                            </td>
                            <td>{{ @$data->firstItem()+$k }}</td>
                            {{--<td>{{ $v->id }}</td>--}}
                            <td>{{ @$v->abbr }}</td>
                            <th>{{ ts('mdtype'.@$v->mdtype) }}</th>
                            <td>
                                @if ($show == 1)
                                    <a href="/admin/distributor/{{ @$v->sdid }}">{{ @$v->sdqy }}</a>
                                @else
                                    {{ @$v->sdqy }}
                                @endif
                            </td>
                            <td>{{ @$v->first_name }}</td>
                            <td>{{ rsPN(@$v->phone_number) }}</td>
                            <td>
                                {{ @$v->deleted_at ? ts('jy') : ts('DEACTIVE') }}
                            </td>
                            <td  class="fixed-td text-center" style="width:270px">
                                @if (!empty($menus) && in_array('look', $menus))
                                <a class="btn btn-success btn-sm" href='/admin/dealer/{{ $v->id }}'>{{ ts('VIEW') }}</a>
                                @endif
                                @if (!empty($menus) && (in_array('enabled', $menus) || in_array('disabled', $menus)))
                                @if(session('admin.user_type') == 1)
                                    @empty($v->deleted_at)
                                        <span class="btn btn-danger btn-sm" onclick="editDealerStatus('{{ $v->id }}', '{{ $v->status }}', '{{ $v->abbr }}')">{{ $v->status != 1 ? ts('active') : ts('DEACTIVE') }}</span>
                                    @endif
                                @endif
                                @endif
                                @if (!empty($menus) && in_array('work', $menus))
                                @empty(getDPN($v->id))
                                    <span class="btn btn-dark btn-sm disabled">{{ ts('performance') }}</span>
                                @else
                                    <a class="btn btn-primary btn-sm" href='/admin/dealer/{{ $v->id }}/performance'>{{ ts('performance') }}</a>
                                @endif
                                @endif
                            </td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
            <div class="row my-3">
                {{--<div class="col-auto">
                    <label style="cursor: pointer"><input type="checkbox" class="icheck_all" data-ele=".roll_icheck"><span class="ml-2">{{ ts('SELECTALL') }}</span></label>
                    <span class="btn btn-primary ml-3" onclick="deleteAlliCheck('.roll_icheck', '/admin/dealer/deletes')">{{ ts('delete') }}</span>
                </div>--}}
                <div class="col">
                    {{ $data->appends(request()->input())->links() }}
                </div>
            </div>
        </div>


    </div>


@endsection

@section('script')
    <script>
        $(document).ready(function () {
            $('.table.bt-table').bootstrapTable({
                fixedColumns: true,
                fixedNumber: 1,
                fixedRightNumber: 1,
            }).removeClass('d-none')
        })
    </script>
@endsection